class Node {
    constructor(e) {
        this.element = e;
        this.next = null;
    }
};
class CirclarLinkedList {
    constructor() {
        this.head = new Node('head');
        this.head.next = this.head
    };
    find(item) {
        let currNode = this.head;
        while (currNode.element != item) {
            currNode = currNode.next
        };
        return currNode
    };
    findPrevious(item) {
        let currNode = this.head;
        while (currNode.next != null && currNode.next.element != item) {
            currNode = currNode.next;
        };
        return currNode
    };
    insert(newElement, item) {
        let newNode = new Node(newElement);
        let currNode = this.find(item);
        newNode.next = currNode.next;
        currNode.next = newNode
    };
    remove(item) {
        let prevNode = this.findPrevious(item);
        prevNode.next = prevNode.next.next;
    };
    dispaly() {
        let currNode = this.head;
        while (currNode.next.element != 'head') {
            console.log(currNode.next.element);
            currNode = currNode.next
        }
    }
}